package JSE_01.Date.Demo_02;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Demo02Test {
    public static void main(String[] args) throws ParseException {
        Date date=new Date();
        System.out.println(date);  //Tue Aug 10 15:44:37 CST 2021
        System.out.println("===============");
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入您的出生日期,格式为:yyyy-MM-dd");
        String birthdayDateString=sc.next();
        System.out.println(birthdayDateString); // 2021-08-01
        System.out.println("===============");
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        Date birthdayDate=sdf.parse(birthdayDateString); // Mon Jul 12 00:00:00 CST 2021
        System.out.println(birthdayDate);

        System.out.println("===============");
        long birthdayDateTime=birthdayDate.getTime();
        long todayTime=new Date().getTime();

        long time=todayTime-birthdayDateTime;

        System.out.println(time/1000/60/60/24);

    }
}
